<template>
  <dv-digital-flop :config="config" style="height: 2vw"/>
</template>

<style scoped>

</style>

<script>
  /**
   * 数字翻牌器
   */
  export default {
    props: {
      number: {
        type: Number,
        default: 0
      },
      fontSize: {
        type: Number,
        default: 18
      },
      color: {
        type: String,
        default: "#ffffff"
      },
      toFixed: {
        type: Number,
        default: 2
      },
      type: {
        type: Number,
        default: undefined
      },
      height: {
        type: String,
        default: "2vw"
      },
    },
    computed: {
      config: function() {
        let content = '{nt}';
        if (this.number === null) {
          content = "无数据";
        }
        switch (this.type) {
          case 1:
            content = '{nt} m/s';
            break;
          case 2:
            content = '{nt} MPa';
            break;
          case 3:
            content = '{nt} mm';
            break;
          default:
            break;
        }
        return {
          number: [this.number],
          content: content,
          toFixed: this.toFixed,
          style: {
            fontSize: this.fontSize,
            fill: this.color,
            height: this.height,
          },
        };
      }
    }
  };
</script>
